package com.L1ngg.Demo1.apiDemo;

import java.util.ArrayList;

public class ArrayListText1 {
    public static void main(String[] args) {

        //创建一个集合
        ArrayList<String> list = new ArrayList<>();

        //向集合当中添加元素
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");

        //遍历集合
        System.out.print("[");
        for (int i = 0; i < list.size(); i++) {
            if(i == list.size() - 1)
                System.out.print(list.get(i));
            else
                System.out.print(list.get(i)+",");
        }
        System.out.print("]");
    }
}
